package com.cnswhy.cloud.server.core.dao;

import com.cnswhy.cloud.common.core.base.mapper.SuperMapper;
import com.cnswhy.cloud.server.core.entity.ShopClassifySpec;

import com.cnswhy.cloud.server.core.entity.ShopClassifySpecQuery;
import com.cnswhy.cloud.server.core.entity.SpellOrder;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * 商品分类与规格关系表
 * </p>
 *
 * @author cnswhy
 * @date 2020-11-18
 */
@Repository
public interface ShopClassifySpecMapper extends SuperMapper<ShopClassifySpec> {
    @Select("select \n" +
            "          t.id,\n" +
            "          t.spec_name,\n" +
            "          t.sort_order,\n" +
            "          t.spec_type,\n" +
            "          t.customize,\n" +
            "          t.status,\n" +
            "          bs.has_img,\n" +
            "          #{productId} productId\n" +
            "      from \n" +
            "          t_shop_spec t\n" +
            "      left join \n" +
            "          t_shop_classify_spec bs\n" +
            "      on bs.spec_id = t.id\n" +
            "      where t.status = 0\n" +
            "        and bs.classify_id = #{classifyId}\n" +
            "      order by t.sort_order")
    List<ShopClassifySpecQuery> querySpecListByClassify(@Param("productId") Long productId, @Param("classifyId") Long classifyId);
}
